<include file="Public:header" />
<form action="" method="" class="definewidth m20" id="company-form">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">企业名称</td>
        <td><input type="text" name="name"/></td>
    </tr>
    <tr>
        <td class="tableleft">企业法人</td>
        <td>
            <select name="user_id">
                <foreach name="user_list" item="r_val">
                    <option value="{$r_val['user_id']}">{$r_val.nickname|default=$r_val.name}({$r_val.user_id})</option>
                </foreach>
            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">地址</td>
        <td><input type="text" name="address"/></td>
    </tr>

    <tr>
        <td class="tableleft">联系电话</td>
        <td><input type="text" name="phone"/></td>
    </tr>
    <tr>
        <td class="tableleft">传真</td>
        <td><input type="text" name="fax"/></td>
    </tr>
    <tr>
        <td class="tableleft">开户银行</td>
        <td><input type="text" name="bank"/></td>
    </tr>
    <tr>
        <td class="tableleft">银行账户(开户人名称)</td>
        <td><input type="text" name="bank_user"/></td>
    </tr>
    <tr>
        <td class="tableleft">银行账号(银行卡号)</td>
        <td><input type="text" name="bank_no"/></td>
    </tr>
    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="button" class="btn btn-primary" type="button" id="add-company">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
        </td>
    </tr>
</table>
</form>

<script>
    $(function () {
        $('#backid').click(function(){
            window.location.href="{:U('Company/Index')}";
        });
        $("#add-company").click(function () {
            data = $("#company-form").serialize();
            $.post(
                    "{:U('Company/save')}",
                    data,
                    function(xhr){
                        if(200 == xhr.status){
                            alert(xhr.msg);
                            location.href = "{:U('Company/Index')}"
                        }else {
                            alert(xhr.msg);
                        }
                    }
            );
        });

    });
</script>

<include file="Public:footer" />